package com.ssy.lingxi.order.model.bo;

import com.ssy.lingxi.order.model.constant.BuyerInnerStatusEnum;
import com.ssy.lingxi.order.model.constant.OrderOuterStatusEnum;
import com.ssy.lingxi.order.model.constant.OrderServiceContants;
import com.ssy.lingxi.order.model.constant.VendorInnerStatusEnum;
import com.ssy.lingxi.workflow.api.model.vo.response.ComplexTaskCompleteVO;

import java.io.Serializable;

/**
 * 工作流执行任务结果
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-19
 */
public class ProcessTaskBO implements Serializable {
    private static final long serialVersionUID = -5851537903192993576L;

    public ProcessTaskBO() {
    }

    public ProcessTaskBO(ComplexTaskCompleteVO completeVO, Boolean startProcess) {
        this.taskId = completeVO.getTaskId();
        this.buyerInnerStatus = startProcess ? Integer.valueOf(completeVO.getOuterProperties().getOrDefault(OrderServiceContants.PROCESS_BUYER_INNER_STATUS_KEY, String.valueOf(BuyerInnerStatusEnum.ACCOMPLISHED.getCode()))) : Integer.valueOf(completeVO.getInnerProperties().getOrDefault(OrderServiceContants.PROCESS_BUYER_INNER_STATUS_KEY, String.valueOf(BuyerInnerStatusEnum.ACCOMPLISHED.getCode())));
        this.vendorInnerStatus = startProcess ? Integer.valueOf(completeVO.getOuterProperties().getOrDefault(OrderServiceContants.PROCESS_VENDOR_INNER_STATUS_KEY, String.valueOf(VendorInnerStatusEnum.ACCOMPLISHED.getCode()))) : Integer.valueOf(completeVO.getInnerProperties().getOrDefault(OrderServiceContants.PROCESS_VENDOR_INNER_STATUS_KEY, String.valueOf(VendorInnerStatusEnum.ACCOMPLISHED.getCode())));
        this.outerStatus = startProcess ? Integer.valueOf(completeVO.getOuterProperties().getOrDefault(OrderServiceContants.PROCESS_OUTER_STATUS_KEY, String.valueOf(OrderOuterStatusEnum.ACCOMPLISHED.getCode()))) : Integer.valueOf(completeVO.getInnerProperties().getOrDefault(OrderServiceContants.PROCESS_OUTER_STATUS_KEY, String.valueOf(OrderOuterStatusEnum.ACCOMPLISHED.getCode())));
        this.nextPay = startProcess ? completeVO.getOuterProperties().containsKey(OrderServiceContants.PROCESS_NEXT_PAY_KEY) : completeVO.getInnerProperties().containsKey(OrderServiceContants.PROCESS_NEXT_PAY_KEY);
        this.nextSerialNo = startProcess ? Integer.valueOf(completeVO.getOuterProperties().getOrDefault(OrderServiceContants.PROCESS_NEXT_PAY_KEY, "0")) : Integer.valueOf(completeVO.getInnerProperties().getOrDefault(OrderServiceContants.PROCESS_NEXT_PAY_KEY, "0"));
        this.payTask = completeVO.getOuterProperties().containsKey(OrderServiceContants.PROCESS_PAY_KEY);
        this.payStartNode = Integer.valueOf(completeVO.getOuterProperties().getOrDefault(OrderServiceContants.PROCESS_PAY_START_KEY, "0"));
        this.payEndNode = Integer.valueOf(completeVO.getOuterProperties().getOrDefault(OrderServiceContants.PROCESS_PAY_END_KEY, "0"));
    }

    /**
     * 流程任务Id
     */
    private String taskId;

    /**
     * 采购商内部状态
     */
    private Integer buyerInnerStatus;

    /**
     * 供应商内部状态
     */
    private Integer vendorInnerStatus;

    /**
     * 订单外部状态
     */
    private Integer outerStatus;

    /**
     * 下一个步骤是支付（用于判断创建订单后是否立即支付）
     */
    private Boolean nextPay;

    /**
     * 下一个支付批次（定义在流程图中的nextPay属性中）
     */
    private Integer nextSerialNo;

    /**
     * 当前任务是否属于支付流程
     */
    private Boolean payTask;

    /**
     * 当前支付流程的起始支付次数
     */
    private Integer payStartNode;

    /**
     * 当前支付流程的结束支付次数
     */
    private Integer payEndNode;

    public String getTaskId() {
        return taskId;
    }

    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }

    public Integer getBuyerInnerStatus() {
        return buyerInnerStatus;
    }

    public void setBuyerInnerStatus(Integer buyerInnerStatus) {
        this.buyerInnerStatus = buyerInnerStatus;
    }

    public Integer getVendorInnerStatus() {
        return vendorInnerStatus;
    }

    public void setVendorInnerStatus(Integer vendorInnerStatus) {
        this.vendorInnerStatus = vendorInnerStatus;
    }

    public Integer getOuterStatus() {
        return outerStatus;
    }

    public void setOuterStatus(Integer outerStatus) {
        this.outerStatus = outerStatus;
    }

    public Boolean getNextPay() {
        return nextPay;
    }

    public void setNextPay(Boolean nextPay) {
        this.nextPay = nextPay;
    }

    public Integer getNextSerialNo() {
        return nextSerialNo;
    }

    public void setNextSerialNo(Integer nextSerialNo) {
        this.nextSerialNo = nextSerialNo;
    }

    public Boolean getPayTask() {
        return payTask;
    }

    public void setPayTask(Boolean payTask) {
        this.payTask = payTask;
    }

    public Integer getPayStartNode() {
        return payStartNode;
    }

    public void setPayStartNode(Integer payStartNode) {
        this.payStartNode = payStartNode;
    }

    public Integer getPayEndNode() {
        return payEndNode;
    }

    public void setPayEndNode(Integer payEndNode) {
        this.payEndNode = payEndNode;
    }
}
